// components/search-result/search-result.js
Component({
      /**
       * 组件的属性列表
       */
      properties: {
        value: String,
        p: Number,
        isSearch: Boolean
      },

      /**
       * 组件的初始数据
       */
      data: {
        result: null,
        filters: null,
        order: null,
        cate: null,
        list: [],
      },
      time: -1,
      observers: {
        // value(n){
        //   clearTimeout(this.time);
        //   if(!n.trim())return;
        //   this.time = setTimeout(()=>{
        //     this.getData();
        //   },1000);
        // },
        result(n) {
          // this.getData();
          let filters = n.filter.type.map(item => {
            return {
              text: item.key,
              value: item.value
            }
          });
          let cate = n.filter.cate.map(item => {
            return {
              text: item.catename,
              value: item.cateid
            }
          })
          cate.unshift({
            text: "全部频道",
            value: ""
          });
          let order = n.order.map(item => {
            return {
              text: item.key,
              value: item.value
            }
          })
          this.setData({
            filters: filters,
            cate: cate,
            order: order,
          })
        },
        p(n) {
          this.pushList();
        },
        isSearch() {
          this.getData();
        },
      },  
        /**
         * 组件的方法列表
         */
        methods: {
          pushList() {
            wx.request({
              url: `http://api.kele8.cn/agent/https://app.vmovier.com/apiv3/search?kw=${this.data.value}&p=${this.data.p}`,
              success: (res) => {
                this.setData({
                  list: [...this.data.list, ...res.data.data.result.list]
                })
              }
            })
          },
          getData() {
            wx.request({
              url: `http://api.kele8.cn/agent/https://app.vmovier.com/apiv3/search?kw=${this.data.value}&p=${this.data.p}`,
              success: (res) => {
                this.setData({
                  result: res.data.data,
                  list: res.data.data.result ? [...res.data.data.result.list] : []
                })
              }
            })
          }
        },
        lifetimes: {
          attached() {
            // this.getData();
          }
        }
      })